package com.smartwork.common.sms;

import com.smartwork.common.config.Global;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class SmsUtil {

    private static Logger log = LoggerFactory.getLogger(SmsUtil.class);

    private static final String url = Global.getConfig("sms.url");// 应用地址
    private static final String account = Global.getConfig("sms.account");// 账号
    private static final String pswd = Global.getConfig("sms.pswd");// 密码
    public static void sendMsg(final String mobile, final String message) {
        new Thread(){
            @Override
            public void run() {
                try {
                    String returnString = HttpSender.batchSend(url, account, pswd, mobile, message, true, null, null);
                    if (returnString.split(",")[1].equals("0")) {
                        log.error("短信发送错误{}！{}", returnString.split(",")[1], mobile);
                    }
                } catch (Exception e) {
                    log.error("{}", e);
                }
            }
        }.start();
    }

}
